package com.example.admin.goodnews.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.admin.goodnews.R;
import com.example.admin.goodnews.entity.GoodNewsClassEntity;

import java.util.List;

/**
 * 主页侧滑菜单里用于显示分类信息的ListView的适配器
 * Created by admin on 2016/9/28.
 */

public class ListViewAdapter extends BaseAdapter {
    private Context context;
    // private GoodNewsClassEntity goodNewsClassEntity;
    private List<String> lists;

//    public SlideMenuListViewAdapter(Context context, GoodNewsClassEntity goodNewsClassEntity) {
//        this.context = context;
//        this.goodNewsClassEntity = goodNewsClassEntity;
//    }


    public ListViewAdapter(Context context, List<String> lists) {
        this.context = context;
        this.lists = lists;
    }

    @Override
    public int getCount() {
        return lists.size();
    }

    @Override
    public Object getItem(int position) {
        return lists.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        if (convertView == null) {
            convertView = LayoutInflater.from(context).inflate(R.layout.item_listview_acitivity_main, null);
            holder = new ViewHolder();
            holder.tv_item_listview_slidemenu = (TextView) convertView.findViewById(R.id.tv_item_listview_slidemenu);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        holder.tv_item_listview_slidemenu.setText(lists.get(position));
        return convertView;
    }

    public class ViewHolder {
        private TextView tv_item_listview_slidemenu;
    }
}
